<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Session extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(4)
     *
     * @var int
     */
    protected $_IdSession;

    /**
     * Database var type varchar(200)
     *
     * @var string
     */
    protected $_Titre;

    /**
     * Database var type int(2)
     *
     * @var int
     */
    protected $_TypeSession;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DateDebut;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DateFin;

    /**
     * Database var type int(1)
     *
     * @var int
     */
    protected $_Etat;

    /**
     * Database var type int(2)
     *
     * @var int
     */
    protected $_CertificationIdCertification;


    /**
     * Parent relation fk_session_certification1
     *
     * @var Application_Model_Certification
     */
    protected $_Certification;


    /**
     * Dependent relation fk_actualites_session1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Actualites
     */
    protected $_Actualites;

    /**
     * Dependent relation fk_resultat_session_session1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_ResultatSession
     */
    protected $_ResultatSession;

    /**
     * Dependent relation fk_salle_session1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Salle
     */
    protected $_Salle;

    /**
     * Dependent relation fk_session_enseignant_surveillant_session1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_SessionEnseignantSurveillant
     */
    protected $_SessionEnseignantSurveillant;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_session'=>'IdSession',
            'titre'=>'Titre',
            'type_session'=>'TypeSession',
            'date_debut'=>'DateDebut',
            'date_fin'=>'DateFin',
            'etat'=>'Etat',
            'certification_id_certification'=>'CertificationIdCertification',
        ));

        $this->setParentList(array(
            'FkSessionCertification1'=> array(
                    'property' => 'Certification',
                    'table_name' => 'Certification',
                ),
        ));

        $this->setDependentList(array(
            'FkActualitesSession1' => array(
                    'property' => 'Actualites',
                    'table_name' => 'Actualites',
                ),
            'FkResultatSessionSession1' => array(
                    'property' => 'ResultatSession',
                    'table_name' => 'ResultatSession',
                ),
            'FkSalleSession1' => array(
                    'property' => 'Salle',
                    'table_name' => 'Salle',
                ),
            'FkSessionEnseignantSurveillantSession1' => array(
                    'property' => 'SessionEnseignantSurveillant',
                    'table_name' => 'SessionEnseignantSurveillant',
                ),
        ));
    }

    /**
     * Sets column id_session
     *
     * @param int $data
     * @return Application_Model_Session
     */
    public function setIdSession($data)
    {
        $this->_IdSession = $data;
        return $this;
    }

    /**
     * Gets column id_session
     *
     * @return int
     */
    public function getIdSession()
    {
        return $this->_IdSession;
    }

    /**
     * Sets column titre
     *
     * @param string $data
     * @return Application_Model_Session
     */
    public function setTitre($data)
    {
        $this->_Titre = $data;
        return $this;
    }

    /**
     * Gets column titre
     *
     * @return string
     */
    public function getTitre()
    {
        return $this->_Titre;
    }

    /**
     * Sets column type_session
     *
     * @param int $data
     * @return Application_Model_Session
     */
    public function setTypeSession($data)
    {
        $this->_TypeSession = $data;
        return $this;
    }

    /**
     * Gets column type_session
     *
     * @return int
     */
    public function getTypeSession()
    {
        return $this->_TypeSession;
    }

    /**
     * Sets column date_debut
     *
     * @param date $data
     * @return Application_Model_Session
     */
    public function setDateDebut($data)
    {
        $this->_DateDebut = $data;
        return $this;
    }

    /**
     * Gets column date_debut
     *
     * @return date
     */
    public function getDateDebut()
    {
        return $this->_DateDebut;
    }

    /**
     * Sets column date_fin
     *
     * @param date $data
     * @return Application_Model_Session
     */
    public function setDateFin($data)
    {
        $this->_DateFin = $data;
        return $this;
    }

    /**
     * Gets column date_fin
     *
     * @return date
     */
    public function getDateFin()
    {
        return $this->_DateFin;
    }

    /**
     * Sets column etat
     *
     * @param int $data
     * @return Application_Model_Session
     */
    public function setEtat($data)
    {
        $this->_Etat = $data;
        return $this;
    }

    /**
     * Gets column etat
     *
     * @return int
     */
    public function getEtat()
    {
        return $this->_Etat;
    }

    /**
     * Sets column certification_id_certification
     *
     * @param int $data
     * @return Application_Model_Session
     */
    public function setCertificationIdCertification($data)
    {
        $this->_CertificationIdCertification = $data;
        return $this;
    }

    /**
     * Gets column certification_id_certification
     *
     * @return int
     */
    public function getCertificationIdCertification()
    {
        return $this->_CertificationIdCertification;
    }

    /**
     * Sets parent relation CertificationIdCertification
     *
     * @param Application_Model_Certification $data
     * @return Application_Model_Session
     */
    public function setCertification(Application_Model_Certification $data)
    {
        $this->_Certification = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_certification'];
        }

        $this->setCertificationIdCertification($primary_key);

        return $this;
    }

    /**
     * Gets parent CertificationIdCertification
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Certification
     */
    public function getCertification($load = true)
    {
        if ($this->_Certification === null && $load) {
            $this->getMapper()->loadRelated('FkSessionCertification1', $this);
        }

        return $this->_Certification;
    }

    /**
     * Sets dependent relations fk_actualites_session1
     *
     * @param array $data An array of Application_Model_Actualites
     * @return Application_Model_Session
     */
    public function setActualites(array $data)
    {
        $this->_Actualites = array();

        foreach ($data as $object) {
            $this->addActualites($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_actualites_session1
     *
     * @param Application_Model_Actualites $data
     * @return Application_Model_Session
     */
    public function addActualites(Application_Model_Actualites $data)
    {
        $this->_Actualites[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_actualites_session1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Actualites
     */
    public function getActualites($load = true)
    {
        if ($this->_Actualites === null && $load) {
            $this->getMapper()->loadRelated('FkActualitesSession1', $this);
        }

        return $this->_Actualites;
    }

    /**
     * Sets dependent relations fk_resultat_session_session1
     *
     * @param array $data An array of Application_Model_ResultatSession
     * @return Application_Model_Session
     */
    public function setResultatSession(array $data)
    {
        $this->_ResultatSession = array();

        foreach ($data as $object) {
            $this->addResultatSession($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_resultat_session_session1
     *
     * @param Application_Model_ResultatSession $data
     * @return Application_Model_Session
     */
    public function addResultatSession(Application_Model_ResultatSession $data)
    {
        $this->_ResultatSession[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_resultat_session_session1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_ResultatSession
     */
    public function getResultatSession($load = true)
    {
        if ($this->_ResultatSession === null && $load) {
            $this->getMapper()->loadRelated('FkResultatSessionSession1', $this);
        }

        return $this->_ResultatSession;
    }

    /**
     * Sets dependent relations fk_salle_session1
     *
     * @param array $data An array of Application_Model_Salle
     * @return Application_Model_Session
     */
    public function setSalle(array $data)
    {
        $this->_Salle = array();

        foreach ($data as $object) {
            $this->addSalle($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_salle_session1
     *
     * @param Application_Model_Salle $data
     * @return Application_Model_Session
     */
    public function addSalle(Application_Model_Salle $data)
    {
        $this->_Salle[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_salle_session1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Salle
     */
    public function getSalle($load = true)
    {
        if ($this->_Salle === null && $load) {
            $this->getMapper()->loadRelated('FkSalleSession1', $this);
        }

        return $this->_Salle;
    }

    /**
     * Sets dependent relations fk_session_enseignant_surveillant_session1
     *
     * @param array $data An array of Application_Model_SessionEnseignantSurveillant
     * @return Application_Model_Session
     */
    public function setSessionEnseignantSurveillant(array $data)
    {
        $this->_SessionEnseignantSurveillant = array();

        foreach ($data as $object) {
            $this->addSessionEnseignantSurveillant($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_session_enseignant_surveillant_session1
     *
     * @param Application_Model_SessionEnseignantSurveillant $data
     * @return Application_Model_Session
     */
    public function addSessionEnseignantSurveillant(Application_Model_SessionEnseignantSurveillant $data)
    {
        $this->_SessionEnseignantSurveillant[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_session_enseignant_surveillant_session1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_SessionEnseignantSurveillant
     */
    public function getSessionEnseignantSurveillant($load = true)
    {
        if ($this->_SessionEnseignantSurveillant === null && $load) {
            $this->getMapper()->loadRelated('FkSessionEnseignantSurveillantSession1', $this);
        }

        return $this->_SessionEnseignantSurveillant;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Session
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Session());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Session::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdSession() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_session = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdSession()));
    }
}
